﻿<UserControl 
    x:Class="MTGenome.Views.DeckView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:caliburn="http://www.caliburnproject.org"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="300"
    caliburn:Message.Attach="Loaded">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <ListView  Grid.Column="0" BorderThickness="0" ItemsSource="{Binding Creatures}" Width="auto" SelectedItem="{Binding SelectedCard}" caliburn:Message.Attach="[Event SelectionChanged] = [Action CardSelected]" >
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn  Header="Creatures" DisplayMemberBinding="{Binding Text}" />
                </GridView>
            </ListView.View>
            <ListView.ContextMenu>
                <ContextMenu>
                    <ContextMenu.ItemsSource>
                        <CompositeCollection>
                            <MenuItem Header="Remove 1 From Deck" caliburn:Message.Attach="RemoveOneOfSelectedCardFromDeck" />
                            <MenuItem Header="Remove 4 From Deck" caliburn:Message.Attach="RemoveFourOfSelectedCardFromDeck" />
                            <MenuItem Header="Remove All From Deck" caliburn:Message.Attach="RemoveAllOfSelectedCardFromDeck" />
                        </CompositeCollection>
                    </ContextMenu.ItemsSource>
                </ContextMenu>
            </ListView.ContextMenu>
        </ListView>

        <ListView  Grid.Column="1" BorderThickness="0"  ItemsSource="{Binding Spells}" Width="auto" SelectedItem="{Binding SelectedCard}" caliburn:Message.Attach="[Event SelectionChanged] = [Action CardSelected]">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Spells" DisplayMemberBinding="{Binding Text}" />
                </GridView>
            </ListView.View>
            <ListView.ContextMenu>
                <ContextMenu>
                    <ContextMenu.ItemsSource>
                        <CompositeCollection>
                            <MenuItem Header="Remove 1 From Deck" caliburn:Message.Attach="RemoveOneOfSelectedCardFromDeck" />
                            <MenuItem Header="Remove 4 From Deck" caliburn:Message.Attach="RemoveFourOfSelectedCardFromDeck" />
                            <MenuItem Header="Remove All From Deck" caliburn:Message.Attach="RemoveAllOfSelectedCardFromDeck" />
                        </CompositeCollection>
                    </ContextMenu.ItemsSource>
                </ContextMenu>
            </ListView.ContextMenu>
        </ListView>

        <ListView  Grid.Column="2" BorderThickness="0" ItemsSource="{Binding Lands}" Width="auto" SelectedItem="{Binding SelectedCard}" caliburn:Message.Attach="[Event SelectionChanged] = [Action CardSelected]">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Lands" DisplayMemberBinding="{Binding Text}"  />
                </GridView>
            </ListView.View>
            <ListView.ContextMenu>
                <ContextMenu>
                    <ContextMenu.ItemsSource>
                        <CompositeCollection>
                            <MenuItem Header="Remove 1 From Deck" caliburn:Message.Attach="RemoveOneOfSelectedCardFromDeck" />
                            <MenuItem Header="Remove 4 From Deck" caliburn:Message.Attach="RemoveFourOfSelectedCardFromDeck" />
                            <MenuItem Header="Remove All From Deck" caliburn:Message.Attach="RemoveAllOfSelectedCardFromDeck" />
                        </CompositeCollection>
                    </ContextMenu.ItemsSource>
                </ContextMenu>
            </ListView.ContextMenu>
        </ListView>

        <ListView  Grid.Column="3" BorderThickness="0" ItemsSource="{Binding Sideboard}" Width="auto" SelectedItem="{Binding SelectedCard}" caliburn:Message.Attach="[Event SelectionChanged] = [Action CardSelected]">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Sideboard" DisplayMemberBinding="{Binding Text}" />
                </GridView>
            </ListView.View>
            <ListView.ContextMenu>
                <ContextMenu>
                    <ContextMenu.ItemsSource>
                        <CompositeCollection>
                            <MenuItem Header="Remove 1 From Sideboard" caliburn:Message.Attach="RemoveOneOfSelectedCardFromSideboard" />
                            <MenuItem Header="Remove 4 From Sideboard" caliburn:Message.Attach="RemoveFourOfSelectedCardFromSideboard" />
                            <MenuItem Header="Remove All From Sideboard" caliburn:Message.Attach="RemoveAllOfSelectedCardFromSideboard" />
                        </CompositeCollection>
                    </ContextMenu.ItemsSource>
                </ContextMenu>
            </ListView.ContextMenu>
        </ListView>
        
        

        <!--<ListView Margin="10" Grid.ColumnSpan="3" ItemsSource="{Binding Cards}" >
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="300" Header="Card" DisplayMemberBinding="{Binding Text}" />
                    <GridViewColumn Width="100" Header="Quantity">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBox Text="{Binding UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, Path=Quantity}" TextAlignment="Right" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>

        <StackPanel Orientation="Horizontal" Grid.Row="1">
            <TextBlock Margin="5" Text="Total Cards: " />
            <TextBlock Margin="5" Text="{Binding TotalCards}" />
        </StackPanel>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1">
            <Button Margin="5" caliburn:Message.Attach="AddCard">
                <StackPanel Orientation="Horizontal">
                    <Image Source="{StaticResource AddIcon}" />
                    <TextBlock Margin="2">Add</TextBlock>
                </StackPanel>
            </Button>
            <Button Margin="5" caliburn:Message.Attach="RemoveCard">
                <StackPanel Orientation="Horizontal">
                    <Image Source="{StaticResource DeleteIcon}" />
                    <TextBlock Margin="2">Remove</TextBlock>
                </StackPanel>
            </Button>
        </StackPanel>-->
    </Grid>
</UserControl>
